package com.ruoyi.web.api.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.Area;
import com.ruoyi.system.service.IAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 区域信息操作处理
 *
 * @author ruoyi
 */
@Api(tags = "区域管理")
@RestController
@RequestMapping("/system/area")
public class AreaController extends BaseController {

    private final IAreaService areaService;

    public AreaController(IAreaService areaService) {
        this.areaService = areaService;
    }

    /**
     * 获取区域列表
     */
    @ApiOperation(value = "获取区域列表", notes = "获取所有区域信息")
    @GetMapping("/list")
    public TableDataInfo list(Area area) {
        startPage();
        List<Area> list = areaService.selectAreaList(area);
        return getDataTable(list);
    }

    /**
     * 根据区域编号获取详细信息
     */
    @ApiOperation(value = "获取区域详细信息", notes = "根据id获取区域详细信息")
    @ApiImplicitParam(name = "id", value = "区域ID", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(areaService.selectAreaById(id));
    }
}